<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../js/vue.global.js"></script>
    <title>拼名字</title>
</head>
<body>
    <div id="app">
        姓: <input type="text" v-model="xing">
        名: <input type="text" v-model="ming">
        <h1>使用双向绑定实现：</h1>
        <h1>{{xing}}{{ming}}</h1>

        <h1>使用函数实现</h1>
        <h1>{{linkName()}}</h1>

        <h1>使用计算属性实现</h1>
        <h1>{{linkMyName}}</h1>
    </div>

    <script>
        const myApp = {
            data()
            {
                return {
                    xing: '张',
                    ming: '三'
                }
            },
            methods:
            {
                linkName()
                {
                    return this.xing + this.ming;
                }
            },
            computed:
            {
                linkMyName()
                {
                    return this.xing + this.ming;
                }
            }
        }

        Vue.createApp(myApp).mount("#app");
    </script>
</body>
</html>